<template>
  <div class="topNav">
    <div class="content">
      <div class="back" @click="goBack">
        <img src="../../../assets/my/rightarrow.png" alt="" />
      </div>
      <h3>{{ props.title }}收货地址</h3>
      <p @click="choose">{{ props.update }}</p>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";

const store=useStore()
const router = useRouter();
let props = defineProps({
  title: {
    type: String,
    required: true,
  },
  update: {
    type: String,
    required: true,
  },
});
let goBack = () => {
  store.commit("changeRouterType", "back");
  if (props.title=='管理') {
    router.push('/my');
  } else {
    router.push('/myAddress');
  }
};
const emits = defineEmits(["send", "save", "jump"]);
const choose = () => {
  if (props.title=='管理') {
    jump()
  }
  else if (props.title == "新建") {
    send();
  } else if (props.title == "编辑") {
    save();
  }
};

const send = () => {
  emits("send");
};
const save = () => {
  emits("save");
};
const jump = () => {
  emits("jump");
};
</script>

<style lang="scss" scoped>
.topNav {
  width: 100%;
  background-color: white;

  .content {
    margin: 0 auto;
    width: 97vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    h3 {
      margin: 0;
      font-weight: normal;
      font-size: 4vw;
      color: #333333;
    }
    p {
      color: #333333;
      font-size: 4vw;
    }
    .back {
      width: 4vw;
      height: 3vh;
      transform: rotate(180deg);
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
